import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { forkJoin } from 'rxjs';
import { HttpService } from '../common/http.service';
import { FirstService } from '../first.service';

@Component({
  selector: 'ne-admin',
  templateUrl: './admin.component.html',
  styleUrls: ['./admin.component.scss']
})
export class AdminComponent implements OnInit {


  constructor(
    private httpService: HttpService,
    private firstService: FirstService
  ) {

  }

  ngOnInit(): void {
    let todoRequests: any[] = [
      this.httpService.getTodos(1),
      this.httpService.getTodos(2),
      this.httpService.getTodos(3),
      this.httpService.getTodos(4),
      this.httpService.getTodos(5)
    ]

    forkJoin(todoRequests).subscribe((responses) => {
      console.log(responses)
    })
    
  }

  public onRegister(registerData: any) {
    console.log(registerData);
    const {email} = registerData;
    this.firstService.setEmail(email);
    this.httpService.registerUser(registerData).subscribe((response) => {
      console.log(response);
    },(error) => {
      console.log("Error", error);
    });
  }

}
